

// 此reducer只处理books
const initBooks =  [
    {
      id:"01001",
      name:"如何让富婆爱上你"
    },
    {
      id:"01002",
      name:"霸道男总裁"
    }
  ]


const reducer=(books=initBooks,action)=>{
    console.log("reducer:action",action);
      switch(action.type){
        case "ADDBOOK":{
          // books.push(action.payload);
          return [...books,action.payload];
        }
        case "DELBOOK":return books.filter(item=>item.id!==action.payload);
        default:return books;
      }
  }
  
  export default reducer;